package com.goddess.yeecolor.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.goddess.yeecolor.Modle.tradeInfo;
import com.goddess.yeecolor.R;
import com.goddess.yeecolor.interfaceAll.OnClickListener;

import java.util.List;

/**
 * 行业 职业
 */
public class ProfessionTradeAdapter extends RecyclerView.Adapter<ProfessionTradeAdapter.ViewHode>{

    private OnClickListener onClickListener;
    private Context mContext;
    private List<tradeInfo>mList;
    public ProfessionTradeAdapter(Context context,List<tradeInfo>list){
        this.mContext=context;
        this.mList=list;
    }

    @Override
    public ViewHode onCreateViewHolder(ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(mContext).inflate(R.layout.item_professiontrad,parent,false);
        ViewHode viewHode=new ViewHode(view);
        return viewHode;
    }

    @Override
    public void onBindViewHolder(ViewHode holder, int position) {
        holder.item_professionname.setText(mList.get(position).getName());

    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    public class ViewHode extends RecyclerView.ViewHolder{
        private TextView item_professionname;
        public ViewHode(View itemView) {
            super(itemView);
            item_professionname= (TextView) itemView.findViewById(R.id.item_professionname);
            itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    onClickListener.OnClick(view,getLayoutPosition());
                }
            });
        }
    }

    public void setOnClickListerner(OnClickListener onClickListerner){
        this.onClickListener=onClickListerner;
    }
}
